<?php 
define('ACC', true);
require('../include/init.php');
$_POST['goods_weight'] *= $_POST['weight_unit'];
$data=$_POST;
$uptool=new UpTool();
$ori_img=$uptool->up();
$data['ori_img']=$ori_img['ori_img'];

$ori=ROOT.$ori_img['ori_img'];
$goods_img=dirname($ori).'/goods_'.basename($ori);
if(ImageTool::thumb($ori,$goods_img,100,100)){
	$data['goods_img']=	str_replace(ROOT,'',$goods_img);
}
$thumb_img=dirname($ori).'/thumb_'.basename($ori);
if(ImageTool::thumb($ori,$thumb_img,100,80)){
	$data['thumb_img']=	str_replace(ROOT,'',$thumb_img);
}

$ins=new goods_Model();
if (empty($data['goods_sn'])) {
	$data['goods_sn']=$ins->createSn();
}

$data=$ins->_facade($data);
$data=$ins->_auto($data);
if($ins->_validate($data)){
	echo '添加成功';
}else{
print_r($ins->getErr());
}
// exit;
$row=$ins->add($data);
if (!$row){
	echo '添加失败';
}else{
	echo '添加成功';
}

